﻿@using CommonSite.Common
@using CommonLibrary.Models
<table class="tt-table" border="1" cellspacing="0" bordercolor="#000">
    <tr class="c1">
        <td class="col" style="width:20%">申请日期:</td>
        <td class="col" style="width:30%">@ViewBag.Flow["creationtime"]</td>
        <td class="col" style="width:20%">
            申请人:
        </td>
        <td class="col" style="width:30%">
            @ViewBag.Flow["username"]
        </td>
    </tr>
    <tr class="c1">
        <td class="col" style="width:20%">申请部门:</td>
        <td class="col" style="width:80%" colspan="3">
            @ViewBag.Flow["dept"]
        </td>
    </tr>
    @foreach (var item in ViewBag.Fields)
    {
    <tr class="@string.Format("c{0}", item.ControlId)">
        <td class="col" style="width:20%">@item.Name:</td>
        <td class="col" style="width:80%;padding:0px;" colspan="3">
            @if(item.ControlId != 10)
            {
            <div style="padding-left:2%;padding-right:2%;">
                @(TemplateHelper.FormatValue(item, ViewBag.Row["field_" + item.Id]))&nbsp;
            </div>
            }
            else
            {
                // item.Source
                // item.Id 
                // (int)ViewBag.Row["id"]
                List<wf_Column> hlist = TemplateHelper.GetTableHeader(item.Source);  
                <table style="width:100%;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:-20px" border="0" cellspacing="0" cellpadding="0" bordercolor="#000">
                    <tr>
                        @for (int k = 0; k < hlist.Count; k++)
                        {
                            var hd = hlist[k];
                            if (k == 0)
                            { 
                                <td style="text-align:center;">
                                    @hd.ColumnName
                                </td>
                            }
                            else
                            { 
                                <td style="text-align:center;border-left:1px solid;">
                                    @hd.ColumnName
                                </td>
                            }
                        }
                    </tr>
                    @{
                        System.Data.DataTable dt = TemplateHelper.GetTableValues(item, (int)ViewBag.Row["id"]);
                        foreach(System.Data.DataRow row in dt.Rows)
                        {
                            <tr>
                            @for (int i = 2; i < dt.Columns.Count; i++)
                            {
                                if(i==2)
                                {
                                    <td style="border-top:1px solid;border-right:1px solid;">
                                    @row[i].ToString()
                                    </td>
                                }
                                else if(i==dt.Columns.Count-1)
                                {
                                    <td style="border-top:1px solid;border-left:1px solid;">
                                    @row[i].ToString()
                                    </td>
                                }
                                else
                                {
                                    <td style="border-top:1px solid;border-left:1px solid;border-right:1px solid;">
                                    @row[i].ToString()
                                    </td>
                                }
                            }
                            </tr>
                        }
                      }
                </table>
                
            }
        </td>
    </tr>
    }
</table>
